import React, { Component } from "react";
interface OneInter {
  count: number;
}
export default class LifeCycle extends Component<any, OneInter> {
  constructor(state: any, context: any) {
    super(state, context);

    this.state = {
      count: 1,
    };
    console.log("这是constructor" + this.state.count);
  }
  componentDidMount() {
    this.setState((state, props) => ({
      count: state.count + 1,
    }));
    console.log("componentDidMount开始了");
  }
  componentDidUpdate() {
    console.log("componentDidUpdate更新了");
  }
  changefun = () => {
    this.setState({
      count: 4,
    });
  };
  render() {
    console.log(1);
    return (
      <div>
        {this.state.count}
        <button onClick={this.changefun}>更新</button>
      </div>
    );
  }
}
